package xp2p.inter.server;


/**
 * The Class ServerRunner.
 */
public class ServerRunner
{
	private int _fails;
	private int _port;
	private Server _server;
	private HandlerFactory factory;
	
	public ServerRunner(int port, HandlerFactory factory)
	{
		_port = port;
		this.factory = factory;
	}
	
	public void startSever()
	{
		while (_fails < 16)
		{
			_server = new Server(_port, factory);
			_server.start();
			if (_server.wasFailure())
			{
				_fails++;
			}
			else
			{
				return;
			}
		}
	}
	
	public void stopServer()
	{
		_server.stop();
	}

	public int getPort()
	{
		return _port;
	}

	public void setPort(int _port)
	{
		this._port = _port;
	}
}
